package vip.xiaonuo.facedoor.rule;

import cn.hutool.core.util.ObjectUtil;
import lombok.Data;
import lombok.experimental.Accessors;
import vip.xiaonuo.core.exception.ServiceException;
import vip.xiaonuo.facedoor.iservice.*;


@Data
@Accessors(chain = true)
public class DeviceTypeRuleService {

    public static IDeviceBaseService getIDeviceBaseService(String deviceType) {
        if (ObjectUtil.equal(deviceType, "1") || ObjectUtil.equal(deviceType, "5")) {
            return DwRulesEngine.deviceBaseService;
        } else if (ObjectUtil.equal(deviceType, "7")) {
            return HQRulesEngine.deviceBaseService;
        } else if (ObjectUtil.equal(deviceType, "4")) {
            return VeinRulesEngine.deviceBaseService;
        } else {
            return null;
        }
    }


    public static IMemberDealWithService getIMemberDealWithService(String deviceType) {
        if (ObjectUtil.equal(deviceType, "7")) {
            return HQRulesEngine.memberDealWithService;
        } else if (ObjectUtil.equal(deviceType, "4")) {
            return VeinRulesEngine.memberDealWithService;
        } else if (ObjectUtil.equal(deviceType, "10")) {
            return HTRulesEngine.memberDealWithService;
        } else {
            return DwRulesEngine.memberDealWithService;
        }
    }

    public static IVisitorDealWithService getIVisitorDealWithService(String deviceType) {
        if (ObjectUtil.equal(deviceType, "7")) {
            return HQRulesEngine.visitorDealWithService;
        } else if (ObjectUtil.equal(deviceType, "4")) {
            throw new ServiceException(500, "设备类型4不存在访客");
        } else if (ObjectUtil.equal(deviceType, "10")) {
            return HTRulesEngine.visitorDealWithService;
        } else {
            return DwRulesEngine.visitorDealWithService;
        }
    }


    public static IVisitorDeviceService getIVisitorDeviceService(String deviceType) {
        if (ObjectUtil.equal(deviceType, "7")) {
            return HQRulesEngine.visitorDeviceService;
        } else if (ObjectUtil.equal(deviceType, "4")) {
            throw new ServiceException(500, "设备类型4不存在访客");
        } else if (ObjectUtil.equal(deviceType, "10")) {
            return HTRulesEngine.visitorDeviceService;
        } else {
            return DwRulesEngine.visitorDeviceService;
        }
    }

    public static IMemberDeviceService getIMemberDeviceService(String deviceType) {
        if (ObjectUtil.equal(deviceType, "7")) {
            return HQRulesEngine.memberDeviceService;
        } else if (ObjectUtil.equal(deviceType, "4")) {
            return VeinRulesEngine.memberDeviceService;
        } else if (ObjectUtil.equal(deviceType, "10")) {
            return HTRulesEngine.memberDeviceService;
        } else {
            return DwRulesEngine.memberDeviceService;
        }

    }


}
